import 'package:android_studio_f/pages/HomePage.dart';
import 'package:android_studio_f/pages/EditCredentialPage.dart';
import 'package:flutter/material.dart';

const indexPage = "/";
const editCredentialName = "/editCredential";

Map<String, dynamic> routers = {
  indexPage: (ctx) => const MyApp(),
  editCredentialName: (ctx, [args]) => EditCredential(detail: args)
};

RouteFactory genRouterFunc = (setting) {
  var renderFunc = routers[setting.name];
  return MaterialPageRoute(builder: (ctx) {
    if (renderFunc == null) {
      return Center(child: Text("页面不存在"));
    }
    if (setting.arguments == null) {
      return renderFunc(ctx);
    }
    return renderFunc(ctx, setting.arguments);
  });
};
